#!/usr/bin/env python
#coding:utf-8

import urllib
import chardet
import sys

def testchardet(myurl):
    usock = urllib.urlopen(myurl).read()
    mychar = chardet.detect(usock)
    #print mychar
    for k in mychar:
        print '%s---->%s' % (k, mychar[k])

if __name__ == '__main__':

    if len(sys.argv) == 2:
        testchardet(sys.argv[1])
    else:
        print '''网站编码测试工具. v0.01'''
        print 'Usage:testchardet url'
    
